#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "simplechatserver.h"

static const quint16 DEFAULT_PORT = 6667;

// ----------------------------------------------------------------------------------
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}
// ----------------------------------------------------------------------------------
MainWindow::~MainWindow()
{
    delete ui;
}
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
void MainWindow::writeToLCD(int i)
{
    if(ui->lcdNumber->value()<10000)
    {
        ui->lcdNumber->display(ui->lcdNumber->value()*10+i);
    }
}
// ----------------------------------------------------------------------------------
void MainWindow::pb1()
{
    writeToLCD(1);
}
// ----------------------------------------------------------------------------------
void MainWindow::pb2()
{
    writeToLCD(2);
}
// ----------------------------------------------------------------------------------
void MainWindow::pb3()
{
    writeToLCD(3);
}
// ----------------------------------------------------------------------------------
void MainWindow::pb4()
{
    writeToLCD(4);
}
// ----------------------------------------------------------------------------------
void MainWindow::pb5()
{
    writeToLCD(5);
}
// ----------------------------------------------------------------------------------
void MainWindow::pb6()
{
    writeToLCD(6);
}
// ----------------------------------------------------------------------------------
void MainWindow::pb7()
{
    writeToLCD(7);
}
// ----------------------------------------------------------------------------------
void MainWindow::pb8()
{
    writeToLCD(8);
}
// ----------------------------------------------------------------------------------
void MainWindow::pb9()
{
    writeToLCD(9);
}
// ----------------------------------------------------------------------------------
void MainWindow::pb0()
{
    writeToLCD(0);
}
// ----------------------------------------------------------------------------------
void MainWindow::pbA()
{
    int i = ui->lcdNumber->value()/10;
    ui->lcdNumber->display(i);
}
// ----------------------------------------------------------------------------------
void MainWindow::pbB()
{
    ui->lcdNumber->display("Active");
}
// ----------------------------------------------------------------------------------
void MainWindow::pbexCom()
{
    SimpleChatServer server;
    server.listen(QHostAddress::Any, DEFAULT_PORT);
    qDebug() << "start\n";
}
// ----------------------------------------------------------------------------------


